from PyQt4 import QtGui, QtCore; #@UnusedImport

class Settings_Align(QtCore.QObject):    
    def __init__(self, parent):
        super(Settings_Align, self).__init__();
        self.parent = parent;
        self.mainWin = parent.mainWin;
        self.graphScene = parent.graphScene;
        self.createSettings_Align();
        
    def createSettings_Align(self):
        #Labels
        self.lblAlign_Left = QtGui.QLabel('Left', self.mainWin);
        self.lblAlign_Right = QtGui.QLabel('Right', self.mainWin);
        self.lblAlign_CenterH = QtGui.QLabel('CenterH', self.mainWin);
        self.lblAlign_CenterV = QtGui.QLabel('CenterV', self.mainWin);
        self.lblAlign_Top = QtGui.QLabel('Top', self.mainWin);
        self.lblAlign_Bottom = QtGui.QLabel('Bottom', self.mainWin);
        #Buttons
        self.btnAlign_Left = QtGui.QPushButton(QtGui.QIcon('Images/align_Left.png'), '', self.mainWin);
        self.btnAlign_Left.setMinimumSize(40,40)
        self.btnAlign_Right = QtGui.QPushButton(QtGui.QIcon('Images/align_Right.png'), '', self.mainWin);
        self.btnAlign_Right.setMinimumSize(40,40)
        self.btnAlign_CenterH = QtGui.QPushButton(QtGui.QIcon('Images/align_CenterH.png'), '', self.mainWin);
        self.btnAlign_CenterH.setMinimumSize(40,40)
        self.btnAlign_CenterV = QtGui.QPushButton(QtGui.QIcon('Images/align_CenterV.png'), '', self.mainWin);
        self.btnAlign_CenterV.setMinimumSize(40,40)
        self.btnAlign_Top = QtGui.QPushButton(QtGui.QIcon('Images/align_Top.png'), '', self.mainWin);
        self.btnAlign_Top.setMinimumSize(40,40)
        self.btnAlign_Bottom = QtGui.QPushButton(QtGui.QIcon('Images/align_Bottom.png'), '', self.mainWin);
        self.btnAlign_Bottom.setMinimumSize(40,40)
        #Connect Btns
        self.btnAlign_Left.connect(self.btnAlign_Left, QtCore.SIGNAL("clicked()"), self.alignNodesLeft);
        self.btnAlign_Right.connect(self.btnAlign_Right, QtCore.SIGNAL("clicked()"), self.alignNodesRight);
        self.btnAlign_CenterH.connect(self.btnAlign_CenterH, QtCore.SIGNAL("clicked()"), self.alignNodesCenterH);
        self.btnAlign_CenterV.connect(self.btnAlign_CenterV, QtCore.SIGNAL("clicked()"), self.alignNodesCenterV);
        self.btnAlign_Top.connect(self.btnAlign_Top, QtCore.SIGNAL("clicked()"), self.alignNodesTop);
        self.btnAlign_Bottom.connect(self.btnAlign_Bottom, QtCore.SIGNAL("clicked()"), self.alignNodesBottom);
        #Set Layout
        self.gridLayout = QtGui.QGridLayout();
        self.gridLayout.addWidget(self.btnAlign_Left,0,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.btnAlign_Right,0,1, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_Left,1,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_Right,1,1, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.btnAlign_CenterH,2,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.btnAlign_CenterV,2,1, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_CenterH,3,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_CenterV,3,1, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.btnAlign_Top,4,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.btnAlign_Bottom,4,1, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_Top,5,0, QtCore.Qt.AlignCenter);
        self.gridLayout.addWidget(self.lblAlign_Bottom,5,1, QtCore.Qt.AlignCenter);
        self.qWidget = QtGui.QWidget(self.mainWin);
        self.qWidget.setLayout(self.gridLayout);
        self.vBoxMain = QtGui.QVBoxLayout();
        self.vBoxMain.addWidget(self.qWidget); 
    
    #Graph - Align Nodes    
    def alignNodesLeft(self):
        self.graphScene.graphView.alignNodesLeft();
    def alignNodesRight(self):
        self.graphScene.graphView.alignNodesRight();
    def alignNodesCenterH(self):
        self.graphScene.graphView.alignNodesCenterH();
    def alignNodesCenterV(self):
        self.graphScene.graphView.alignNodesCenterV();
    def alignNodesTop(self):
        self.graphScene.graphView.alignNodesTop();
    def alignNodesBottom(self):
        self.graphScene.graphView.alignNodesBottom();
